package uz.edo.app.client.ui.doc;

import java.util.Date;

import org.apache.wicket.datetime.PatternDateConverter;
import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.extensions.yui.calendar.DatePicker;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.PropertyModel;

import uz.edo.app.client.MyPage;
import uz.edo.db.bean.Registrationdoc;
import uz.edo.db.manager.RegistrationdocManager;

public class RegistrationDocAdd extends MyPage{

    private RegistrationdocManager registrationmanager = RegistrationdocManager.getInstance();
    private Registrationdoc registrationdoc;

   @SuppressWarnings("unchecked")
	public RegistrationDocAdd() {
    	registrationdoc = new Registrationdoc();
        CompoundPropertyModel model = new CompoundPropertyModel(registrationdoc);
        Form form = new Form("form",model){
		private static final long serialVersionUID = 5658583493027664252L;

		@Override
        protected void onSubmit() {
	    try {
	    		registrationmanager.saveOrUpdate(registrationdoc);
	            setResponsePage(DocListView.class);
	        } catch(Exception e) {
	            e.printStackTrace();
	        }
        }
        };
        add(form);
        form.add(new RequiredTextField("personfio"));
        form.add(new TextField("murojaatDescription"));
        form.add(new DateTextField("murojaatDate", "dd.MM.yyyy").add(new DatePicker()));
    }
}
